import axios from 'axios'
import qs from 'qs'
function doGet(url, params) {
    return new Promise((resolve, reject) => {
        axios.get(url, {
            params: params,
            paramsSerializer: function (params) {
                return qs.stringify(params, {arrayFormat: 'brackets'})
            },
        },).then(res => {
            console.info(res);
            resolve(res.data);
        }).catch(err => {
            reject(err.response)
        })
    });
}
function doPost(url, params) {
    return new Promise((resolve, reject) => {
        axios.post(url, params)
            .then(res => {
                resolve(res.data);
            })
            .catch(err =>{
                reject(err.data)
            })
    });
}
function doPostUnlencoded(url, params) {
    return new Promise((resolve, reject) => {
        axios.post(url, qs.stringify(params))
            .then(res => {
                resolve(res.data);
            })
            .catch(err =>{
                console.info(err.response)
                reject(err.response)
            })
    });
}
export {
    doGet, doPost, doPostUnlencoded
}
